<HTML>
<HEAD>
<TITLE>JavaScript Source Code 3000:  Password Protection:  Login Coder</TITLE>
<META HTTP-EQUIV="JavaScript Source Code 3000" CONTENT = "no-cache">
<META NAME="date" CONTENT="2000-09-09">
<META NAME="channel" CONTENT="Web Developer">
<META NAME="author" CONTENT="Dion (yobo42@hotmail.com)">
<META NAME="section" CONTENT="Password Protection">
<META NAME="description" CONTENT="This is undoubtedly the best password protection JavaScript you'll ever find.  Besides supporting multiple users, multiple passwords, and even multiple destination pages (after they successfully login), this script is presented in a very easy-to-use interface that you're sure to love!  We *wish* we wrote this script, it's that good!  (Note:  Questions on this script should be directed to the author via email:  yobo42@hotmail.com)">
</HEAD>

<BODY BGCOLOR=#ffffff vlink=#0000ff>

<BR>
<center>
<table width="600" cellpadding="0" cellspacing="10">
<tr>
<td width="468" align="center">

	
</td>
<td width="120" align="center">

	
</td>
</tr>
</table>
<BR>
<BR>
<BASEFONT SIZE=3>
  <FONT SIZE=6>
<B><FONT SIZE="+2" FACE="Helvetica,Arial" ALIGN=RIGHT COLOR="#0000FF">
<b><A HREF="../index.htm" /" TARGET="_top">
Home</A> </b><img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}"> <b><A HREF="index.htm" /passwords/"><font color="#FF0000">Password Protection</font></A> </b>
<img src="../img/arrow.gif" /img/arrow.gif" height=13 width=7 border=0 alt="}"> <FONT COLOR="#006666">Login Coder</FONT></b></FONT><BR>
</B><BR>
  </FONT>
<TABLE BORDER=0 WIDTH=500 CELLPADDING=3 CELLSPACING=0>
<tr><td><font FACE=" helvetica,arial,geneva">
<br>
<!-- Description --><!--content_start-->


<TABLE border=0 cellspacing=1 cellpadding=1>
<TR><TD colspan=2 bgcolor=#000000>
<TABLE width=550 cellspadding=3 cellspacing=0 border=0>
<TR><TD width=550 height=25 bgcolor=#FFFFCC valign=middle align=center>
<FONT face="verdana, arial" size="-1"><a href="javascript:if(confirm('http://www.iinet.net.au/~biab/  \n\nYou must be connected to the Internet to view this link.  \n\nDo you want to open it from the server?'))window.location='http://www.iinet.net.au/~biab/'" tppabs="http://www.iinet.net.au/~biab/">Login Coder Web Site</a><p>
<a href="javascript:if(confirm('http://www.iinet.net.au/~biab/  \n\nYou must be connected to the Internet to view this link.  \n\nDo you want to open it from the server?'))window.location='http://www.iinet.net.au/~biab/'" tppabs="http://www.iinet.net.au/~biab/">Help, FAQs, modifications, and tons of great script info!</a></font>
</TD></TR></TABLE>
</TD></TR></TABLE>
<br>
<br>
This is undoubtedly the best password protection JavaScript you'll ever find.  Besides supporting multiple users, multiple passwords, and even multiple destination pages (after they successfully login), this script is presented in a very easy-to-use interface that you're sure to love!  We *wish* we wrote this script, it's that good!  (Note:  Questions on this script should be directed to the <a href="javascript:if(confirm('http://www.iinet.net.au/~biab/  \n\nYou must be connected to the Internet to view this link.  \n\nDo you want to open it from the server?'))window.location='http://www.iinet.net.au/~biab/'" tppabs="http://www.iinet.net.au/~biab/">author</a>.)<br><hr>
</td></tr>
</table>
<!--  Demonstration -->
<center><table border=1>
<tr><form name=members><td rowspan=4>
<select name=memlist size=10 onChange="showmem(this.form)">

<!-- Original:  Dion (yobo42@hotmail.com) -->
<!-- Web Site:  http://www.iinet.net.au/~biab/ -->




<!-- "member name | password | destination pagename |" -->
<option selected value="John Smith|password|mainpage|">John Smith
<option value="Peter Jones|theirpwd|endpages|">Peter Jones
<option value="Sue Brown|asdfvcxz|nowheres|">Sue Brown
<option value="Sally West|zaqxswde|logintop|">Sally West
</select></td>
<td align=right>User:</td><td><input type=hidden value="0" name=entry>
<input type=text name=memname size=8 value=""></td></tr>
<tr><td align=right>Password:</td><td><input type=text name=password size=8 maxlength=8>  <font size="-1"><-- Must be exactly 8 characters</font></td></tr>
<tr><td align=right>Page Name:</td><td><input type=text name=pagename size=8 maxlength=8><b>.html</b>  <font size="-1"><-- Must be exactly 8 characters</font></td></tr>
<tr><td colspan=2 align=center>
<input type=button value="New User" onclick="addnew(this.form);">
<input type=button value="Delete User" onclick="delthis(this.form);">
<input type=button value="Update/Show Coding" onclick="update(this.form); create(this.form);"></td></tr>
<tr><td colspan=3 align=center>
<input type=text size=60 name=message value="Note:  Password/Page Name must be exactly 8 letters! (a-z)">
<input type=hidden name=num value=1></td>
</form></tr>
</table>
<hr size=2 width=75%>
<form name=js><textarea cols=75 rows=10 name=scrpt wrap=virtual>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var params=new Array(4);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
function check(form) {
which=form.memlist.selectedIndex;
choice = form.memlist.options[which].value+"|";
if (choice=="x|") {
alert("Please Select Your Name From The List");
return;
}
p=0;
for (i=0;i<3;i++) {
a=choice.indexOf("|",p);
params[i]=choice.substring(a,p);
p=a+1;
}
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";
if (h1!=params[1]) {
alert("Incorrect Password!"); return; };
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1)
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a<0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=page.toLowerCase()+".html";
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i<8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End -->
</script>
</textarea>
</form>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var params=new Array(4);
var script=document.js.scrpt.value;
document.js.scrpt.value="Create your users, their passwords, and their destination pages using the form above.\n\nThen, click 'Show Coding' to see the login HTML and JavaScript that you need to put on your page to password-protect your site with that info.\n\nQuestions about this script or how to put it on your site should be directed to it's author:  http://www.iinet.net.au/~biab/\n\n*Honestly, we don't even totally understand this JavaScript!*";
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
showmem(document.members);
function showmem(form) {
document.members.num.value=document.members.memlist.length;
var which=form.memlist.selectedIndex;
splt(form.memlist[which].value);
form.entry.value=which+1;
for (i=2;i<5;i++) {
form.elements[i].value=params[i-2]; };
}
function splt(choice) {
p=0;
for (i=0;i<3;i++) {
a=choice.indexOf("|",p);
params[i]=choice.substring(a,p);
p=a+1;
   }
}
function addnew(form) {
newmem=getfields(form);
var who=prompt("New User's Name:","");
form.memlist[form.memlist.length] = new Option(who, newmem, false, true);
if (navigator.appName=="Netscape") {
document.js.scrpt.value=script;
history.go(0);
}
else {
showmem(document.members);
   }
}
function getfields(form) {
newmem="";
for (i=2;i<5;i++) {
newmem+=form.elements[i].value+"|"; };
for (i=3;i<5;i++) {
}
return(newmem);
}
function delthis(form) {
if (confirm("Delete "+form.memname.value+"?")) {
form.memlist.options[form.entry.value-1]=null;
form.message.value=form.memname.value+" Deleted";
form.memlist.selectedIndex=0;
if (navigator.appName=="Netscape") {
document.js.scrpt.value=script;
history.go(0);
}
else {
showmem(document.members);
      }
   }
}
function update(form) {
msg="no";
a=form.elements[i];
for (k=0;k<8;k++) {
b=a.value.substring(k,k+1);
c=b.toUpperCase();
form.memlist[form.entry.value-1].value=getfields(form);
form.message.value=form.memname.value+"'s record was updated";
   }
}
function create(form) {

var html="<center><form name=login>\n";
html+="<table border=1 cellpadding=3>\n\n";
html+="<!-- Original:  Dion -->\n";
html+="<!-- Web Site:  http://www.iinet.net.au/~biab/ -->\n\n";
html+="\n";
html+="\n\n";
html+='<tr><td colspan=2 align=center><font size="+2"><b>Members-Only Area!</b></font></td></tr>\n';
html+="<tr><td>Username:</td><td><select name=memlist>\n<option value='x'>";
for (j=0;j<form.memlist.length;j++) {
splt(form.memlist.options[j].value);
h1=makehash(params[1],3);
h2=makehash(params[1],10)+" ";
var page="";
for (var i=0;i<8;i++) {
letter=params[2].substring(i,i+1);
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a+=(h2.substring(i,i+1)*1);
page+=alpha.substring(a,a+1);
}
html+="\n<option value='"+params[0]+"|"+h1+"|"+page+"'>"+params[0];
};
html+="\n</select></td></tr>\n";
html+="<tr><td>Password:</td><td><input type=password size=10 maxlength=8 name=pass></td></tr>\n";
html+='<tr><td colspan=2 align=center><input type=button value="Login" onclick="check(this.form)"></td>\n';
html+="</tr>\n</table>\n</form>\n";
document.js.scrpt.value=html+script+"</center>";
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i<8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End -->
</script><P>
</center>
<P>
<BR>
<P>
<a name="source">
<TABLE BORDER=0 WIDTH=500 CELLPADDING=3 CELLSPACING=0>
<tr><td BGCOLOR=yellow><font FACE="helvetica,arial,geneva"><b>JavaScript Source Code 3000:  Password Protection:  Login Coder</b>
<p>Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as NotePad or SimpleText) and save (Control-s or Apple-s).  The script is yours!<br><br></font></td></tr>
<tr><td BGCOLOR=yellow ALIGN=CENTER>
<form NAME="copy">

<DIV align="center">
<input type=button value="Highlight All" onClick="javascript:this.form.txt.focus();this.form.txt.select();">&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE="text" NAME="total" VALUE="Script Size:  6.50 KB  " size="24">
</DIV>

<textarea NAME="txt" ROWS=20 COLS=75 WRAP=VIRTUAL>

&lt;!-- ONE STEP TO INSTALL LOGIN CODER:

   1.  Add the first code into the BODY of your HTML document  --&gt;

&lt;!-- STEP ONE: Add the first code into the BODY of your HTML document  --&gt;

&lt;BODY&gt;

&lt;center&gt;&lt;table border=1&gt;
&lt;tr&gt;&lt;form name=members&gt;&lt;td rowspan=4&gt;
&lt;select name=memlist size=10 onChange="showmem(this.form)"&gt;

&lt;!-- Original:  Dion  --&gt;
&lt;!-- Web Site:  http://www.iinet.net.au/~biab/ --&gt;

&lt;! &gt;
&lt;! &gt;

&lt;!-- "member name | password | destination pagename |" --&gt;
&lt;option selected value="John Smith|password|mainpage|"&gt;John Smith
&lt;option value="Peter Jones|theirpwd|endpages|"&gt;Peter Jones
&lt;option value="Sue Brown|asdfvcxz|nowheres|"&gt;Sue Brown
&lt;option value="Sally West|zaqxswde|logintop|"&gt;Sally West
&lt;/select&gt;&lt;/td&gt;
&lt;td align=right&gt;User:&lt;/td&gt;&lt;td&gt;&lt;input type=hidden value="0" name=entry&gt;
&lt;input type=text name=memname size=8 value=""&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=right&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type=text name=password size=8 maxlength=8&gt;&lt;font size="-1"&gt;&lt;-- Must be exactly 8 characters&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td align=right&gt;Page Name:&lt;/td&gt;&lt;td&gt;&lt;input type=text name=pagename size=8 maxlength=8&gt;&lt;b&gt;.html&lt;/b&gt;&lt;font size="-1"&gt;&lt;-- Must be exactly 8 characters&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=2 align=center&gt;
&lt;input type=button value="New User" onclick="addnew(this.form);"&gt;
&lt;input type=button value="Delete User" onclick="delthis(this.form);"&gt;
&lt;input type=button value="Update/Show Coding" onclick="update(this.form); create(this.form);"&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=3 align=center&gt;
&lt;input type=text size=60 name=message value="Note:  Password/Page Name must be exactly 8 letters! (a-z)"&gt;
&lt;input type=hidden name=num value=1&gt;&lt;/td&gt;
&lt;/form&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;hr size=2 width=75%&gt;
&lt;form name=js&gt;&lt;textarea cols=75 rows=10 name=scrpt wrap=virtual&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Begin
var params=new Array(4);
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
function check(form) {
which=form.memlist.selectedIndex;
choice = form.memlist.options[which].value+"|";
if (choice=="x|") {
alert("Please Select Your Name From The List");
return;
}
p=0;
for (i=0;i&lt;3;i++) {
a=choice.indexOf("|",p);
params[i]=choice.substring(a,p);
p=a+1;
}
h1=makehash(form.pass.value,3);
h2=makehash(form.pass.value,10)+" ";
if (h1!=params[1]) {
alert("Incorrect Password!"); return; };
var page="";
for (var i=0;i&lt;8;i++) {
letter=params[2].substring(i,i+1)
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a-=(h2.substring(i,i+1)*1);
if (a&lt;0) a+=26;
page+=alpha.substring(a,a+1); };
top.location=page.toLowerCase()+".html";
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i&lt;8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End --&gt;
&lt;/script&gt;
&lt;/textarea&gt;
&lt;/form&gt;
&lt;SCRIPT LANGUAGE="JavaScript"&gt;
&lt;!-- Begin
var params=new Array(4);
var script=document.js.scrpt.value;
document.js.scrpt.value="Create your users, their passwords, and their destination pages using the form above.\n\nThen, click 'Show Coding' to see the login HTML and JavaScript that you need to put on your page to password-protect your site with that info.\n\nQuestions about this script or how to put it on your site should be directed to it's author via email:  dion@mailhub.omen.com.au\n\n*Honestly, we don't even totally understand this JavaScript!*";
var alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI";
showmem(document.members);
function showmem(form) {
document.members.num.value=document.members.memlist.length;
var which=form.memlist.selectedIndex;
splt(form.memlist[which].value);
form.entry.value=which+1;
for (i=2;i&lt;5;i++) {
form.elements[i].value=params[i-2]; };
}
function splt(choice) {
p=0;
for (i=0;i&lt;3;i++) {
a=choice.indexOf("|",p);
params[i]=choice.substring(a,p);
p=a+1;
   }
}
function addnew(form) {
newmem=getfields(form);
var who=prompt("New User's Name:","");
form.memlist[form.memlist.length] = new Option(who, newmem, false, true);
if (navigator.appName=="Netscape") {
document.js.scrpt.value=script;
history.go(0);
}
else {
showmem(document.members);
   }
}
function getfields(form) {
newmem="";
for (i=2;i&lt;5;i++) {
newmem+=form.elements[i].value+"|"; };
for (i=3;i&lt;5;i++) {
a=form.elements[i];
for (k=0;k&lt;8;k++) {
   }
}
return(newmem);
}
function delthis(form) {
if (confirm("Delete "+form.memname.value+"?")) {
form.memlist.options[form.entry.value-1]=null;
form.message.value=form.memname.value+" Deleted";
form.memlist.selectedIndex=0;
if (navigator.appName=="Netscape") {
document.js.scrpt.value=script;
history.go(0);
}
else {
showmem(document.members);
      }
   }
}
function update(form) {
msg="no";
a=form.elements[i];
for (k=0;k&lt;8;k++) {
b=a.value.substring(k,k+1);
c=b.toUpperCase();
form.memlist[form.entry.value-1].value=getfields(form);
form.message.value=form.memname.value+"'s record was updated";
   }
}
function create(form) {

var html="&lt;center&gt;&lt;form name=login&gt;\n";
html+="&lt;table border=1 cellpadding=3&gt;\n\n";
html+="&lt;!-- Original:  Dion  --&gt;\n";
html+="&lt;!-- Web Site:  http://www.iinet.net.au/~biab/ --&gt;\n";
html+="&lt;! &gt;\n";
html+="&lt;! &gt;\n\n";
html+='&lt;tr&gt;&lt;td colspan=2 align=center&gt;&lt;font size="+2"&gt;';
html+='&lt;b&gt;Members-Only Area!&lt;/b&gt;&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;\n';
html+="&lt;tr&gt;&lt;td&gt;Username:&lt;/td&gt;&lt;td&gt;&lt;select name=memlist&gt;\n&lt;option value='x'&gt;";
for (j=0;j&lt;form.memlist.length;j++) {
splt(form.memlist.options[j].value);
h1=makehash(params[1],3);
h2=makehash(params[1],10)+" ";
var page="";
for (var i=0;i&lt;8;i++) {
letter=params[2].substring(i,i+1);
ul=letter.toUpperCase();
a=alpha.indexOf(ul,0);
a+=(h2.substring(i,i+1)*1);
page+=alpha.substring(a,a+1);
}
html+="\n&lt;option value='"+params[0]+"|"+h1+"|"+page+"'&gt;"+params[0];
};
html+="\n&lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;\n";
html+="&lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;td&gt;&lt;input type=password size=10 maxlength=8 name=pass&gt;&lt;/td&gt;&lt;/tr&gt;\n";
html+='&lt;tr&gt;&lt;td colspan=2 align=center&gt;&lt;input type=button value="Login" onclick="check(this.form)"&gt;&lt;/td&gt;\n';
html+="&lt;/tr&gt;\n&lt;/table&gt;\n&lt;/form&gt;\n";
document.js.scrpt.value=html+script+"&lt;/center&gt;";
}
function makehash(pw,mult) {
pass=pw.toUpperCase();
hash=0;
for (i=0;i&lt;8;i++) {
letter=pass.substring(i,i+1);
c=alpha.indexOf(letter,0)+1;
hash=hash*mult+c;
}
return(hash);
}
// End --&gt;
&lt;/script&gt;
&lt;/center&gt;

 

&lt;!-- Script Size:  6.50 KB  --&gt;</textarea><br><font FACE="helvetica,arial,geneva"></font></td></tr>

</table>
</form>
</FONT>
</CENTER>


</center>
</body></html>